using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FiltronASP.Logger;

namespace FiltronASP.Models.DAO.WIX
{
    public class WixFiltronCrossDAO : Abstracts.AbstractGenericDAO<WixFiltronCross, System.Nullable<int>>,
        Interfaces.WIX.IWixFiltronCrossDAO
    {
        /// <summary>
        /// Metoda zwracajaca nazwe parametru bedacego kluczem glownym tabeli.
        /// </summary>
        /// <returns>nazwa klucza glownego</returns>
        protected override string GetKeyProperty()
        {
            return "cross_id";
        }

        public IQueryable<WixFiltronCross> getByFiltronFilterId(int filtron_filter_id) 
        {
            if (filtron_filter_id.Equals(0))
            {
                return null;
            }
            try 
            {
                IQueryable<WixFiltronCross> filter = this._cmsEntitiesDataContext.WixFiltronCrosses.Where(
                    cros => cros.filtron_filter_id.Equals(filtron_filter_id)
                    );
                if (!(filter.Any())) 
                {
                    return null;
                }
                return filter;
            }
            catch (Exception ex)
            {
                MyLogger.Log(ex);
            }
            return null;
        }
    }
}
